#include <string>
#include <sstream>

#include "tm_maya_commands.h"
#include "tm_maya_export.h"

#include "tm_maya_plugin.h"

#include <maya/MFnPlugin.h>

using namespace std;

int g_TmVerbosity = 1;
MString g_TmFileName = "";

MStatus initializePlugin( MObject _obj )						
{																
	cout << "Initializing TimidEngine plugin... ";
	
	MFnPlugin plugin( _obj, "TimidEngine", "2011" );

	MStatus stat_export1 = plugin.registerCommand("tm1_export", tm1_export::creator);
	MStatus stat_export2 = plugin.registerCommand("tm2_export", tm2_export::creator);
	
	MStatus stat_getverbosity = plugin.registerCommand("tm_getverbosity", timid_getverbosity::creator);
	MStatus stat_setverbosity = plugin.registerCommand("tm_setverbosity", timid_setverbosity::creator);

	MStatus stat;

	if (!(stat_export1
		&& stat_export2
		&& stat_getverbosity
		&& stat_setverbosity))
		stat.perror("Not all commands were successfully registered");
	else
	{
		stat = MS::kSuccess;

		cout << "success." << endl;
	}

	return stat;												
}

MStatus uninitializePlugin( MObject _obj )						
{																
	cout << endl << "Uninitializing TimidEngine plugin... ";
	
	MFnPlugin plugin( _obj, "TimidEngine", "2011" );			
	
	MStatus stat_export1 = plugin.deregisterCommand("tm1_export");
	MStatus stat_export2 = plugin.deregisterCommand("tm2_export");
	MStatus stat_getverbosity = plugin.deregisterCommand("tm_getverbosity");
	MStatus stat_setverbosity = plugin.deregisterCommand("tm_setverbosity");

	MStatus stat;
	
	if (!(stat_export1
		&& stat_export2
		&& stat_getverbosity
		&& stat_setverbosity))
		stat.perror("Not all commands were successfully deregistered");
	else
	{
		cout << "success." << endl;
		stat = MS::kSuccess;
	}

	return stat;												
}